import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {ZhomeComponent} from './zhome/zhome.component';
import {RegisterComponent} from './register/register.component';
import {LoginComponent} from './login/login.component';
import {OrderComponent} from './order/order.component';
import {ChildAccountComponent} from './order/child-account/child-account.component';
import {ChildAdressComponent} from './order/child-adress/child-adress.component';
import {ChildBrowseComponent} from './order/child-browse/child-browse.component';
import {ChildCollectionComponent} from './order/child-collection/child-collection.component';
import {ChildExchangeComponent} from './order/child-exchange/child-exchange.component';
import {ChildFeedBackComponent} from './order/child-feed-back/child-feed-back.component';
import {ChildIntegralComponent} from './order/child-integral/child-integral.component';
import {ChildIntegralOrderComponent} from './order/child-integral-order/child-integral-order.component';
import {ChildNewComponent} from './order/child-new/child-new.component';
import {ChildOrderComponent} from './order/child-order/child-order.component';
import {ChildPasswordComponent} from './order/child-password/child-password.component';
import {ChildPersonComponent} from './order/child-person/child-person.component';
import {ChildWalletComponent} from './order/child-wallet/child-wallet.component';
import {StchengComponent} from './stcheng/stcheng.component';
import {SjfscComponent} from './sjfsc/sjfsc.component';
import {GeneralComponent} from "./general/general.component";
import {ShopCarComponent} from "./shop-car/shop-car.component";
import {CanAcitveGuard} from "./guard/can-acitve.guard";
import {AuxComponent} from "./aux/aux.component";
import {ChildUpdateComponent} from "./order/child-update/child-update.component";
import {SousuoComponent} from "./sousuo/sousuo.component";

const routes: Routes = [
  {path: '', redirectTo: 'home', pathMatch: 'full'},
  {path: 'toHome', redirectTo: 'home', pathMatch: 'full'},
  {path: 'home', component: ZhomeComponent},
  {path: 'register', component: RegisterComponent},
  {path: 'login', component: LoginComponent},
  {path: 'awallet', redirectTo: 'myOrder/wallet', pathMatch: 'full'},
  {path: 'aexchange', redirectTo: 'myOrder/exchange', pathMatch: 'full'},
  {path: 'stcheng', component: StchengComponent},
  {path: 'sjfsc', component: SjfscComponent},
  {path: 'general/:imgs/:daclass/:xiclass/:depict/:price', component: GeneralComponent},
  {path: 'aux', component: AuxComponent},
  // 搜索框搜索到的页面
  {path: 'sousuo/:imgs/:depict/:price', component: SousuoComponent},
  // 购物车
  {path: 'car', component: ShopCarComponent},
  // 我的订单
  {path: 'myOrder', component: OrderComponent, canActivate: [CanAcitveGuard],
    children: [{path: 'account', component: ChildAccountComponent},
      {path: 'adress', component: ChildAdressComponent},
      {path: 'browse', component: ChildBrowseComponent},
      {path: 'collection', component: ChildCollectionComponent},
      {path: 'exchange', component: ChildExchangeComponent},
      {path: 'feedback', component: ChildFeedBackComponent},
      {path: 'integral', component: ChildIntegralComponent},
      {path: 'integralorder', component: ChildIntegralOrderComponent},
      {path: 'new', component: ChildNewComponent},
      {path: 'order', component: ChildOrderComponent},
      {path: 'password', component: ChildPasswordComponent}
      , {path: 'person', component: ChildPersonComponent},
      {path: 'wallet', component: ChildWalletComponent},
      {path: 'update', component: ChildUpdateComponent}
    ]}

];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
